package top.toptimus.dto.dbSync.syncDatas;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Map;

@NoArgsConstructor
@AllArgsConstructor
@Data
/**
 * 物料预警DTO
 */
public class MaterialAlertDTO {
    private String material_alert_quantity;  //原辅料预警数量
    private String material_id;             //原辅料ID

    /**
     * 将数据放在map集合中
     *
     * @param map
     */
    public MaterialAlertDTO(Map<String, Object> map) {
        this.material_alert_quantity = map.containsKey("material_alert_quantity")?map.get("material_alert_quantity").toString():"";
        this.material_id = map.containsKey("material_id")?map.get("material_id").toString():"";
    }

    /**
     * 将数据放在i_material_alert_s表中
     *
     * @return
     */
    public String MaterialAlertSql() {
        String sql = "INSERT INTO `fragsmart-erp`.`i_material_alert_s` ( `material_alert_quantity`, `material_id` )\n" +
                "VALUES\n" +
                "	( " + this.material_alert_quantity + ", " + this.material_id + " );";

        return sql;
    }
}

